package com.tyros.storage.storage;

import com.tyros.common.kit.log.LogKit;
import com.tyros.storage.enums.StorageType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangshuaiyin
 * @date 2022/2/20 12:30
 */
@Slf4j
@Configuration
public class StorageAutoConfiguration {

    @Bean
    @ConditionalOnProperty(name = "tyros.storage.type", havingValue = StorageType.LOCAL_TYPE)
    public LocalStorageService localStorageService() {
        LogKit.info(log, "{} 文件存储方式初始化.", StorageType.LOCAL_TYPE);
        return new LocalStorageService();
    }

    @Bean
    @ConditionalOnProperty(name = "tyros.storage.type", havingValue = StorageType.ALI_YUN_OSS)
    public AliOssStorageService aliStorageService() {
        LogKit.info(log, "{} 文件存储方式初始化.", StorageType.ALI_YUN_OSS);
        return new AliOssStorageService();
    }
}
